
package com.cap.bts.crmdp.dealer.mars.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cap.bts.crmdp.dealer.mars.dao.IDataConversionLogDao;
import com.cap.bts.crmdp.dealer.mars.domain.DataConversionLog;
import com.cap.bts.crmdp.dealer.mars.service.IDataConversionLogService;
import com.cap.bts.framework.common.exception.AppException;
import com.cap.bts.framework.common.util.Pager;

/**
 *
 */
@Transactional(rollbackFor = AppException.class)
@Service
public class DataConversionLogServiceImpl implements IDataConversionLogService {

	@Autowired
    private IDataConversionLogDao dataConversionLogDaoImpl;

	@Override
	public List<DataConversionLog> queryPage(Pager pager) {
		
		String hql  = "from DataConversionLog order by id desc";
		
		return dataConversionLogDaoImpl.getListByQueryWithDefaultPaging(hql, pager);
	}

	@Override
	public DataConversionLog insert(DataConversionLog dataConversionLog)  {

		return dataConversionLogDaoImpl.save(dataConversionLog);
	}
	
	
	@Override
	public void update(DataConversionLog dataConversionLog)  {
		
		DataConversionLog existPojo = dataConversionLogDaoImpl.findById(dataConversionLog.getId());
		
		existPojo.setSendText(dataConversionLog.getSendText());
		existPojo.setStatus(dataConversionLog.getStatus());
		existPojo.setReturnText(dataConversionLog.getReturnText());
		existPojo.setDescp(dataConversionLog.getDescp());
		existPojo.setLastUpdateDate(new Date());
		
		dataConversionLogDaoImpl.update(existPojo);
	}
    
	@Override
	public List<DataConversionLog> getPendingData(){
		
		String hql  = "from DataConversionLog where status = 1";
		
		return dataConversionLogDaoImpl.getListByQuery(hql);
	}

    
   
}
